<%--
*
* 生成数据
*
--%>
<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ page import="com.sky.fisher.query.PageResult" %>
<%@ page import="com.sky.fisher.model.GridModel" %>
<%@ page import="com.sky.fisher.service.FisherService" %>
<%@ page import="com.sky.common.http.HTTPUtils"%>
<%@ page import="org.apache.commons.logging.Log"%>
<%@ page import="org.apache.commons.logging.LogFactory"%>
<%
	Log logger = LogFactory.getLog(FisherService.class);
	Map<String, String[]> paramters = null;
	String strSQL = null;
	try{
		paramters = request.getParameterMap(); 
		logger.debug("Grid：\n"+paramters.get(FisherService.PARAMETER_GRID)[0]);
		logger.debug("参数：\n"+HTTPUtils.getParameterMap(request));
		long startTime=System.currentTimeMillis();
		GridModel grid = FisherService.getGrid(paramters.get(FisherService.PARAMETER_GRID)[0]); 
		grid.setRequest(request);
		strSQL = FisherService.getSQL(grid,paramters); 
		int pagenumber = Integer.parseInt(paramters.get(FisherService.PARAMETER_PAGE)[0]); 
		int pagesize = Integer.parseInt(paramters.get(FisherService.PARAMETER_PAGESIZE)[0]); 
		PageResult pageResult = FisherService.executeQuery(grid,strSQL, pagenumber, pagesize); 
		pageResult.setTotal(pageResult.getTotal()/pageResult.getPagesize()+(pageResult.getTotal()%pageResult.getPagesize()==0?0:1));//总记录数转换为总页数
		String jsonresult = FisherService.getJSONResult(grid, startTime,pageResult,true); 
		response.setContentType("text/html"); 
		out.println(jsonresult); 
	}catch(Throwable e){		
	  	e.printStackTrace();
	  	logger.error("Grid：\n"+paramters.get(FisherService.PARAMETER_GRID)[0]);
	  	logger.error("参数：\n"+paramters);
	  	logger.error("SQL：\n"+strSQL);
	  	logger.error(e.getMessage(),e);
		throw e;
	}
%>	
